package com.itheima.homework.One;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

public class Demo1 {
    public static void main(String[] args) {

        List<String> list = new ArrayList<>();
        list.add("abc1");
        list.add("abc2");
        list.add("abc3");
        list.add("abc4");

//      for循环遍历
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));

        }

//        迭代器
        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            String next = it.next();
            System.out.println(next);
        }

//        增强for
        for (String s : list) {
            System.out.println(s);
        }

//        foreach
        list.forEach(s -> System.out.println(s));
    }

}
